﻿namespace Bll.Systems
{
    using IDal.Systems;
    using Model.Systems;
    using System;
    using System.Data;
    using System.Web;
    using DALFactory;
    public class WorkLogBll
    {
        private static readonly IWorkLog dal = DataAccess.CreateWorkLog();

        public static void Add(WorkLogEnt model)
        {
            dal.Add(model);
        }

        public static void AddNewLog(string workType, string workNote)
        {
            UserEnt ent = (UserEnt) HttpContext.Current.Session["user"];
            if (ent != null)
            {
                WorkLogEnt model = new WorkLogEnt {
                    ChainNum = ent.ChainNum,
                    CreateTime = DateTime.Now,
                    IpAddress = "127.0.0.1",
                    LoginName = ent.LoginName,
                    UserName = ent.UserName,
                    WorkNote = workNote,
                    WorkType = workType
                };
                Add(model);
            }
        }

        public static void AddNewLog(string workType, string workNote, UserEnt user)
        {
            WorkLogEnt model = new WorkLogEnt {
                ChainNum = user.ChainNum,
                CreateTime = DateTime.Now,
                IpAddress = "127.0.0.1",
                LoginName = user.LoginName,
                UserName = user.UserName,
                WorkNote = workNote,
                WorkType = workType
            };
            Add(model);
        }

        public static void ClearLog()
        {
            dal.ClearLog();
        }

        public static void Delete(int ID)
        {
            dal.Delete(ID);
        }

        public static DataTable GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        public static int GetMaxId()
        {
            return dal.GetMaxId();
        }

        public static WorkLogEnt GetModel(int ID)
        {
            return dal.GetModel(ID);
        }

        public static DataTable GetPageList(int PageSize, int PageIndex, string strWhere)
        {
            return dal.GetPageList(PageSize, PageIndex, strWhere);
        }

        public static void Update(WorkLogEnt model)
        {
            dal.Update(model);
        }
    }
}

